# Maintainer: David Runge <dvzrv@archlinux.org>
# Contributor: speps <speps at aur dot archlinux dot org>

pkgname=xjadeo
pkgver=0.8.12
pkgrel=3
pkgdesc="A simple video player that is synchronized to jack transport"
arch=(loong64 x86_64)
url="https://github.com/x42/xjadeo"
license=(GPL2)
depends=(
  glibc
  imlib2
  libx11
  libxext
  libxpm
  libxv
)
makedepends=(
  alsa-lib
  ffmpeg
  gendesk
  git
  glu
  jack
  libglvnd
  liblo
  libltc
  portmidi
)
backup=(etc/xjadeorc)
source=($url/archive/v$pkgver/$pkgname-v$pkgver.tar.gz)
sha512sums=('c63a18b31e9800cf7f79b90da95bdcaa60c528b586d3a105c47bd514e478e0ff5b8cefd8ada1b9dab51382799fadc297dd26688b648b3475cb33382acf2aa9c0')
b2sums=('8acead9046c24f7d15028f40d60bcdb29fdda128267ee63e173721f6d62e751e3c9983c7fe4831e78a605c5d54d39fef0ef5093b9bf3e51605c44ee928c271d6')

prepare() {
  cd $pkgname-$pkgver
  # https://github.com/x42/xjadeo/issues/54
  # libporttime.so is replaced by libportmidi.so
  sed -e 's/ -lporttime//' -i configure.ac
  gendesk -n \
          --pkgname $pkgname \
          --pkgdesc "$pkgdesc" \
          --categories "AudioVideo;Audio"
  autoreconf -fiv
}

build() {
  cd $pkgname-$pkgver
  ./configure --prefix=/usr --sysconfdir=/etc
  make
}

package() {
  depends+=(
    alsa-lib libasound.so
    ffmpeg libavcodec.so libavformat.so libavutil.so libswscale.so
    freetype2 libfreetype.so
    jack libjack.so
    libglvnd libGL.so
    liblo liblo.so
    libltc libltc.so
    portmidi libportmidi.so
  )

  cd $pkgname-$pkgver
  make DESTDIR="$pkgdir" install
  # config
  install -vDm 644 doc/xjadeorc -t "$pkgdir/etc/"
  # desktop file
  install -vDm 644 $pkgname.desktop -t "$pkgdir/usr/share/applications/"
  # icon
  install -vDm 644 src/$pkgname/icons/xjadeoH128.png "$pkgdir/usr/share/pixmaps/$pkgname.png"
  # docs
  install -vDm 644 {AUTHORS,ChangeLog,NEWS,README} -t "$pkgdir/usr/share/doc/$pkgname/"
}
